package cc.spider.model;

import cc.spider.core.IFetcher;
import cc.spider.core.IDataPipe;
import cc.spider.core.IDataProcessor;
import cc.spider.core.queue.DefaultTaskQueue;
import cc.spider.core.queue.ITaskQueue;
import cc.spider.core.thread.DefaultThreadPool;
import cc.spider.core.thread.IThreadPool;

import java.util.ArrayList;
import java.util.List;

public class SpiderConfig {
    private int sleepTime = 200;
    private int retryTimes = 3;

    private IFetcher fetcher = null;
    private IDataProcessor dataProcess = null;
    private List<IDataPipe> dataPipeList = new ArrayList<>();

    private IThreadPool threadPool = new DefaultThreadPool(10,100);
    private ITaskQueue taskQueue = new DefaultTaskQueue();

    private GlobalDefaultData globalDefaultData = new GlobalDefaultData();

    public IFetcher getFetcher() {
        return fetcher;
    }

    public void setFetcher(IFetcher fetcher) {
        this.fetcher = fetcher;
    }

    public IDataProcessor getDataProcess() {
        return dataProcess;
    }

    public void setDataProcess(IDataProcessor dataProcess) {
        this.dataProcess = dataProcess;
    }

    public List<IDataPipe> getDataPipeList() {
        return dataPipeList;
    }

    public void setDataPipeList(List<IDataPipe> dataPipeList) {
        this.dataPipeList = dataPipeList;
    }

    public int getSleepTime() {
        return sleepTime;
    }

    public void setSleepTime(int sleepTime) {
        this.sleepTime = sleepTime;
    }

    public int getRetryTimes() {
        return retryTimes;
    }

    public void setRetryTimes(int retryTimes) {
        this.retryTimes = retryTimes;
    }

    public GlobalDefaultData getGlobalDefaultData() {
        return globalDefaultData;
    }

    public void setGlobalDefaultData(GlobalDefaultData globalDefaultData) {
        this.globalDefaultData = globalDefaultData;
    }

    public IThreadPool getThreadPool() {
        return threadPool;
    }

    public void setThreadPool(IThreadPool threadPool) {
        this.threadPool = threadPool;
    }

    public ITaskQueue getTaskQueue() {
        return taskQueue;
    }

    public void setTaskQueue(ITaskQueue taskQueue) {
        this.taskQueue = taskQueue;
    }

    public void addDataPipe(IDataPipe dataPipe){
        this.dataPipeList.add(dataPipe);
    }
    public void addDataPipeList(List<IDataPipe> dataPipeList){
        this.dataPipeList.addAll(dataPipeList);
    }
}
